//
//  HomeAddModuleCell.m
//  ZhuoxinAgriculture
//
//  Created by stone on 16/12/4.
//  Copyright © 2016年 stone. All rights reserved.
//

#import "HomeDeleteModuleCell.h"
#import "Masonry.h"
@interface HomeDeleteModuleCell()
/** titleLabel */
@property (weak, nonatomic) UILabel * titleLabel;
/** imageView */
@property (weak, nonatomic) UIImageView * iconImageView;
/** View */
@property (weak, nonatomic) UILabel * subTitleLabel;
@end
@implementation HomeDeleteModuleCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addViews];
        [self setupUI];
        
    }
    return self;
}
- (void)addViews
{
    UILabel * titleLabel = ({
        UILabel * label = [[UILabel alloc] init];
        /** GPU 优化 */
        //        label.opaque = YES;
        //        label.backgroundColor = [UIColor whiteColor];
        //        label.layer.masksToBounds = YES;
        //------------------------------
        label.numberOfLines = 0;
        label.textColor = [UIColor blackColor];
        label.textAlignment = NSTextAlignmentCenter;
        label.text = @"Label的默认内容";
        label.font = [UIFont systemFontOfSize:12];
        
        [self.contentView addSubview:label];
        
        label;
    });
    self.titleLabel = titleLabel;
    
    UILabel * subTitleLabel = ({
        UILabel * label = [[UILabel alloc] init];
        /** GPU 优化 */
        //        label.opaque = YES;
        //        label.backgroundColor = [UIColor whiteColor];
        //        label.layer.masksToBounds = YES;
        //------------------------------
        label.numberOfLines = 0;
        label.textColor = [SNUtils colorWithString:@"7d7c82"];
        label.textAlignment = NSTextAlignmentCenter;
        label.text = @"Label的默认内容";
        label.font = [UIFont systemFontOfSize:9];
        
        [self.contentView addSubview:label];
        
        label;
    });
    self.subTitleLabel = subTitleLabel;
    
    
    
    UIImageView * iconImageView = ({
        UIImageView * imageView = [[UIImageView alloc] init];
        //                imageView.backgroundColor = [UIColor colorWithWhite:0.5 alpha:1.0];
        
        [self.contentView addSubview:imageView];
        
        imageView;
    });
    self.iconImageView = iconImageView;
}
- (void)setupUI
{
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker * make) {
        //        make.left.mas_equalTo(self.contentView.mas_left).offset(0);
        //        make.right.mas_equalTo(self.contentView.mas_right).offset(0);
        make.centerX.mas_equalTo(self.contentView.mas_centerX).offset(0);
        make.top.mas_equalTo(self.contentView.mas_top).offset(15);
        //        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(0);
        
        //        make.width.mas_equalTo(50);
        //        make.height.mas_equalTo(50);
    }];
    
    [self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker * make) {
        //        make.left.mas_equalTo(self.contentView.mas_left).offset(0);
        //        make.right.mas_equalTo(self.contentView.mas_right).offset(0);
        make.centerX.mas_equalTo(self.contentView.mas_centerX).offset(0);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(6);
        //        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(0);
        
        //        make.width.mas_equalTo(50);
        //        make.height.mas_equalTo(50);
    }];
    
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker * make) {
        //        make.left.mas_equalTo(self.contentView.mas_left).offset(0);
        //        make.right.mas_equalTo(self.contentView.mas_right).offset(0);
        make.centerX.mas_equalTo(self.contentView.mas_centerX).offset(0);
        //        make.top.mas_equalTo(self.contentView.mas_top).offset(0);
        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-15);
        
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(50);
        
    }];
}

-(void)setModel:(DBModel *)model{
    _model = model;
    
    self.titleLabel.text = model.title;
    self.subTitleLabel.text = model.subTitle;
    self.titleLabel.textColor = [SNUtils colorWithString:model.titleColorString];
    //    self.subTitleLabel.textColor = [SNUtils colorWithString:model.titleColorString];
    self.iconImageView.image = [UIImage imageNamed:model.iconName];
    
    
    [self.iconImageView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(self.iconImageView.image.size.width );
        make.height.mas_equalTo(self.iconImageView.image.size.height);
    }];
}

-(void)setHomeAddModuleHomeconfigdomain:(HomeAddModuleHomeconfigdomain *)homeAddModuleHomeconfigdomain{
    _homeAddModuleHomeconfigdomain = homeAddModuleHomeconfigdomain;
    
    self.titleLabel.text = homeAddModuleHomeconfigdomain.title;
    self.subTitleLabel.text = homeAddModuleHomeconfigdomain.subTitle;
    self.titleLabel.textColor = [SNUtils colorWithString:homeAddModuleHomeconfigdomain.titleColorString];
    self.iconImageView.image = [UIImage imageNamed:homeAddModuleHomeconfigdomain.sequence];
    
    
    [self.iconImageView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(self.iconImageView.image.size.width );
        make.height.mas_equalTo(self.iconImageView.image.size.height);
    }];
    
}
@end
